package com.woniuxy.caradmin.service.impl;

import com.woniuxy.caradmin.entity.pojo.Unit;
import com.woniuxy.caradmin.entity.vo.UnitVo;
import com.woniuxy.caradmin.mapper.UnitMapper;
import com.woniuxy.caradmin.service.UnitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author womenzu
 * @since 2020-12-07
 */
@Service
public class UnitServiceImpl implements UnitService {
    @Autowired
    private UnitMapper unitMapper;
    @Override
    public List<Unit> selectUnitAll() {
        List<Unit> units = unitMapper.selectUnitAll();
        return units;
    }

    @Override
    public Unit selectUnitById(Integer id) {
        Unit unit = unitMapper.selectUnitById(id);
        return unit;
    }

    @Override
    public boolean addUnit(Unit unitAdd) {
        unitMapper.addUnit(unitAdd);
        return true;
    }

    @Override
    public boolean removeUnitById(Integer id) {
        unitMapper.removeUnitById(id);
        return true;
    }

    @Override
    public boolean updateUnit(Unit unitUpd) {
        unitMapper.updateUnit(unitUpd);
        return true;
    }

    @Override
    public List<Unit> selectUnitByPage(UnitVo unitVo) {
        List<Unit> unitList = unitMapper.selectUnitByPage(unitVo);
        return unitList;
    }

    @Override
    public boolean removeUnitBatch(Integer[] ids) {
        for (Integer id : ids) {
            unitMapper.removeUnitById(id);
        }
        return true;
    }
}
